<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Netty：高性能网络通信框架</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #3a7bd5 0%, #00d2ff 100%);
        }
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .hover-scale {
            transition: all 0.3s ease;
        }
        .hover-scale:hover {
            transform: scale(1.03);
        }
        .highlight {
            position: relative;
            z-index: 1;
        }
        .highlight::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(56, 182, 255, 0.2);
            z-index: -1;
            transition: all 0.3s ease;
        }
        .highlight:hover::after {
            height: 100%;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 md:py-32 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <div class="flex justify-center mb-6">
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm font-medium">高性能网络框架</span>
            </div>
            <h1 class="serif text-4xl md:text-6xl font-bold mb-6 leading-tight">Netty：重新定义网络编程</h1>
            <p class="text-xl md:text-2xl max-w-3xl mx-auto opacity-90 mb-10">一个基于Java NIO的高性能异步网络框架，为现代网络应用提供优雅解决方案</p>
            <div class="flex justify-center space-x-4">
                <a href="#features" class="px-8 py-3 bg-white text-blue-600 font-semibold rounded-full hover:bg-opacity-90 transition-all hover:shadow-lg">核心特性</a>
                <a href="#architecture" class="px-8 py-3 border-2 border-white text-white font-semibold rounded-full hover:bg-white hover:bg-opacity-20 transition-all">架构解析</a>
            </div>
        </div>
    </section>

    <!-- Introduction Section -->
    <section class="py-16 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl">
            <div class="bg-white rounded-2xl shadow-lg p-8 md:p-12 hover-scale">
                <p class="text-lg md:text-xl text-gray-700 leading-relaxed mb-6">
                    Netty 在网络编程中解决了多个关键问题，使其成为一个非常流行的网络通信框架。Netty 通过提供高效的异步 I/O 处理、灵活的编解码机制、优雅的异常处理和高效的线程模型等，解决了许多网络编程中的关键问题，使得开发网络应用变得更加高效和简便。
                </p>
                <div class="flex items-center text-blue-600 font-medium">
                    <i class="fas fa-bolt mr-2"></i>
                    <span>每秒可处理数十万并发连接</span>
                </div>
            </div>
        </div>
    </section>

    <!-- Features Section -->
    <section id="features" class="py-16 px-4 md:px-0 bg-gray-100">
        <div class="container mx-auto max-w-5xl">
            <h2 class="serif text-3xl md:text-4xl font-bold text-center mb-16">Netty 核心优势</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Feature 1 -->
                <div class="feature-card bg-white rounded-xl shadow-md p-8 transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-blue-100 text-blue-600 flex items-center justify-center mr-4">
                            <i class="fas fa-bolt text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">异步和高性能 I/O</h3>
                    </div>
                    <p class="text-gray-600">
                        Netty 提供了高效的异步 I/O 处理，利用非阻塞 I/O 操作来提高系统的吞吐量和响应速度。这使得 Netty 能够处理大量的并发连接而不会因为 I/O 操作而阻塞。
                    </p>
                </div>
                
                <!-- Feature 2 -->
                <div class="feature-card bg-white rounded-xl shadow-md p-8 transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-green-100 text-green-600 flex items-center justify-center mr-4">
                            <i class="fas fa-layer-group text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">简化网络编程</h3>
                    </div>
                    <p class="text-gray-600">
                        Netty 提供了高层次的抽象和大量的现成的功能（如编解码器、协议处理等），使得开发者能够更简单、更高效地实现复杂的网络协议和服务，而无需深入底层的细节。
                    </p>
                </div>
                
                <!-- Feature 3 -->
                <div class="feature-card bg-white rounded-xl shadow-md p-8 transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-purple-100 text-purple-600 flex items-center justify-center mr-4">
                            <i class="fas fa-code text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">灵活的编解码机制</h3>
                    </div>
                    <p class="text-gray-600">
                        Netty 的设计允许开发者灵活地定义数据的编解码方式。通过使用内置的编解码器或自定义编解码器，Netty 能够处理各种数据格式和协议，解决了网络数据传输中的格式化和解析问题。
                    </p>
                </div>
                
                <!-- Feature 4 -->
                <div class="feature-card bg-white rounded-xl shadow-md p-8 transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-red-100 text-red-600 flex items-center justify-center mr-4">
                            <i class="fas fa-exclamation-triangle text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">优雅的异常处理</h3>
                    </div>
                    <p class="text-gray-600">
                        Netty 提供了集中化的异常处理机制，允许开发者在统一的地方处理所有的异常情况，简化了错误处理和恢复操作。
                    </p>
                </div>
                
                <!-- Feature 5 -->
                <div class="feature-card bg-white rounded-xl shadow-md p-8 transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-yellow-100 text-yellow-600 flex items-center justify-center mr-4">
                            <i class="fas fa-microchip text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">高效的线程模型</h3>
                    </div>
                    <p class="text-gray-600">
                        Netty 使用了高效的线程模型，如 Reactor 线程模型，通过将 I/O 操作和业务逻辑分离到不同的线程中，减少了上下文切换的开销，并提高了系统的并发处理能力。
                    </p>
                </div>
                
                <!-- Feature 6 -->
                <div class="feature-card bg-white rounded-xl shadow-md p-8 transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                            <i class="fas fa-network-wired text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">丰富的协议支持</h3>
                    </div>
                    <p class="text-gray-600">
                        Netty 内置了对多种网络协议的支持，如 HTTP、WebSocket、FTP 等，使得开发者能够快速构建支持多种协议的网络应用。
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Architecture Section -->
    <section id="architecture" class="py-16 px-4 md:px-0 bg-white">
        <div class="container mx-auto max-w-5xl">
            <h2 class="serif text-3xl md:text-4xl font-bold text-center mb-12">Netty 架构解析</h2>
            
            <div class="bg-gray-50 rounded-xl p-6 mb-12">
                <div class="mermaid">
                    graph TD
                        A[客户端] -->|请求| B(EventLoopGroup)
                        B --> C[EventLoop 1]
                        B --> D[EventLoop 2]
                        B --> E[EventLoop ...]
                        C --> F[ChannelPipeline]
                        D --> G[ChannelPipeline]
                        E --> H[ChannelPipeline]
                        F --> I[ChannelHandler 1]
                        F --> J[ChannelHandler 2]
                        G --> K[ChannelHandler 1]
                        G --> L[ChannelHandler 2]
                        H --> M[ChannelHandler 1]
                        H --> N[ChannelHandler 2]
                        I --> O[业务逻辑]
                        J --> O
                        K --> O
                        L --> O
                        M --> O
                        N --> O
                </div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-gray-50 p-8 rounded-xl">
                    <h3 class="text-2xl font-bold mb-4 highlight inline-block">事件驱动模型</h3>
                    <p class="text-gray-600 mb-6">
                        Netty 采用了事件驱动的编程模型，允许开发者在特定的事件发生时（如连接建立、数据接收等）执行回调函数。这种机制使得事件处理更加灵活和高效。
                    </p>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>低延迟的事件触发机制</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>细粒度的事件类型划分</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>高效的事件传播路径</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-gray-50 p-8 rounded-xl">
                    <h3 class="text-2xl font-bold mb-4 highlight inline-block">资源管理</h3>
                    <p class="text-gray-600 mb-6">
                        Netty 提供了高效的内存管理和资源回收机制，通过池化技术减少了内存碎片和垃圾回收的开销，提高了系统的整体性能。
                    </p>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>对象池化减少GC压力</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>零拷贝技术提升性能</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>内存泄漏检测机制</span>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <!-- Use Cases Section -->
    <section class="py-16 px-4 md:px-0 bg-gray-100">
        <div class="container mx-auto max-w-5xl">
            <h2 class="serif text-3xl md:text-4xl font-bold text-center mb-12">Netty 典型应用场景</h2>
            
            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-sm hover:shadow-md transition-shadow">
                    <div class="text-blue-500 mb-4">
                        <i class="fas fa-server text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">高性能服务器</h3>
                    <p class="text-gray-600">构建高并发、低延迟的服务器应用，如游戏服务器、金融交易系统等。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm hover:shadow-md transition-shadow">
                    <div class="text-green-500 mb-4">
                        <i class="fas fa-cloud text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">微服务通信</h3>
                    <p class="text-gray-600">作为微服务架构中的通信基础，支持RPC、消息队列等通信方式。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm hover:shadow-md transition-shadow">
                    <div class="text-purple-500 mb-4">
                        <i class="fas fa-comments text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">实时通信</h3>
                    <p class="text-gray-600">构建即时通讯、直播弹幕等需要实时双向通信的应用。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-10">
        <div class="container mx-auto max-w-5xl px-4 md:px-0">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-lg font-semibold text-white">技术小馆</h3>
                    <p class="text-sm mt-1">探索技术的无限可能</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-white transition-colors">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-sm">
                <p>© 2023 技术小馆. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid.js
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            themeVariables: {
                primaryColor: '#E1F0FF',
                primaryBorderColor: '#3a7bd5',
                primaryTextColor: '#333',
                lineColor: '#3a7bd5'
            }
        });
        
        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>